package custom;

import android.support.v7.widget.RecyclerView;
import android.view.View;

import butterknife.ButterKnife;
import interfaces.MyItemClickListener;
import interfaces.MyItemLongClickListener;

/**
 * Created by Administrator on 2018/3/23.
 */

public class RootViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {

    private MyItemClickListener clickListener;
    private MyItemLongClickListener longClickListener;


    public RootViewHolder(View itemView, MyItemClickListener clickListener, MyItemLongClickListener longClickListener) {
        super(itemView);
        ButterKnife.bind(this, itemView);
        itemView.setOnClickListener(this);
        itemView.setOnLongClickListener(this);
        this.clickListener = clickListener;
        this.longClickListener = longClickListener;
    }

    @Override
    public void onClick(View v) {
        if (clickListener != null) {
            clickListener.onItemClick(v, getPosition());
        }
    }

    @Override
    public boolean onLongClick(View v) {
        if (longClickListener != null) {
            longClickListener.onItemLongClick(v, getPosition());
        }
        return true;
    }
}
